import { defHttp } from '/@/utils/http/axios';
import {  WebsiteArticleModel, WebsiteArticleTableRecordModel } from '../model/websiteArticleModel';
import { ErrorMessageMode } from "/#/axios";

enum Api {
  WEBSITEARTICLE_PAGE = '/jxxhWebsite/websiteArticle/getArticleVosPage',
  GET_WEBSITEARTICLEVO_BY_ID = '/jxxhWebsite/websiteArticle/',
  WEBSITEARTICLEVO_SAVE = '/jxxhWebsite/websiteArticle/save',
  WEBSITEARTICLEVO_UPDATE = '/jxxhWebsite/websiteArticle/updateById',
  WEBSITEARTICLEVO_REMOVE = '/jxxhWebsite/websiteArticle/logicalRemoveById/',
}

/**
 * @description: Get sample list value
 */

export const websiteArticleListApi = (params: Object) =>
  defHttp.get<WebsiteArticleTableRecordModel>(
    {url: Api.WEBSITEARTICLE_PAGE,params },
    { errorMessageMode: 'message' }
  );

export const getWebsiteArticleVoByIdApi = (id) =>
  defHttp.get<WebsiteArticleModel>(
    {url: Api.GET_WEBSITEARTICLEVO_BY_ID+id },
    { errorMessageMode: 'message' }
  );

export function websiteArticleSaveApi(params: WebsiteArticleModel, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<WebsiteArticleModel>(
    {
      url: Api.WEBSITEARTICLEVO_SAVE,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
export function websiteArticleUpdateApi(params: WebsiteArticleModel, mode: ErrorMessageMode = 'modal') {
  return defHttp.put<WebsiteArticleModel>(
    {
      url: Api.WEBSITEARTICLEVO_UPDATE,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
export const logicalRemoveById = (id) =>
  defHttp.delete<WebsiteArticleModel>(
    {url: Api.WEBSITEARTICLEVO_REMOVE+id },
    { errorMessageMode: 'message' }
  );
